package com.gongjian.database.dservice;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.gongjian.utile.CodeEntity;
import com.gongjian.utile.Crud;
import com.gongjian.utile.utile.Hump;
import org.apache.ibatis.session.SqlSession;
import org.apache.xmlbeans.impl.xb.ltgfmt.Code;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author donting
 * @Description
 * @create 2019-03-31 11:48
 */
@Service
public class DcourseService {

    @Autowired
    SqlSession sqlSession;

    //获取老师的所有课程
    public String getCours(int userId) {

       List<Map<String,Object>> list= sqlSession.selectList("findAllCourseByUserId",userId);
        CodeEntity codeEntity = new CodeEntity(200,"ok");

//      将查询记录添加到codeEntity

        JSONArray jsonArray = (JSONArray) JSONArray.toJSON(Hump.formatHumpNameForList(list));
        codeEntity.setData(jsonArray);
        return codeEntity.toJSONString();
    }
}
